package com.feinno.urcs.group.entity;

import com.feinno.database.DataRow;
import com.feinno.superpojo.SuperPojo;
import com.feinno.superpojo.annotation.Field;
import com.feinno.urcs.types.MobileNo;

import java.sql.SQLException;

/**
 * @author Li.Hongbo <lihongbo@feinno.com>
 */
public class GroupOfflineMessageIndex extends SuperPojo {

    @Field(id = 1)
    private int groupId;
    @Field(id = 2)
    private MobileNo receiver;
    @Field(id = 3)
    private GroupOfflineMessageType messageType;
    @Field(id = 4)
    private String messageBaseId;
    @Field(id = 5)
    private long groupMessageStorageId;

    public GroupOfflineMessageIndex() {
    }

    public GroupOfflineMessageIndex(DataRow row) throws Exception {
        //    receiver, group_id , message_base_id, group_message_id, message_type
        if (row != null) {
            setGroupId(row.getInt("group_id"));
            setReceiver(MobileNo.parseFrom(row.getString("receiver")));
            setMessageBaseId(row.getString("message_base_id"));
            setGroupMessageStorageId(row.getLong("group_message_id"));
            setMessageType(GroupOfflineMessageType.fromInt(row.getInt("message_type")));
        }

    }


    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        this.groupId = groupId;
    }

    public MobileNo getReceiver() {
        return receiver;
    }

    public void setReceiver(MobileNo receiver) {
        this.receiver = receiver;
    }

    public GroupOfflineMessageType getMessageType() {
        return messageType;
    }

    public void setMessageType(GroupOfflineMessageType messageType) {
        this.messageType = messageType;
    }

    public String getMessageBaseId() {
        return messageBaseId;
    }

    public void setMessageBaseId(String messageBaseId) {
        this.messageBaseId = messageBaseId;
    }

    public long getGroupMessageStorageId() {
        return groupMessageStorageId;
    }

    public void setGroupMessageStorageId(long groupMessageStorageId) {
        this.groupMessageStorageId = groupMessageStorageId;
    }
}
